package com.inspur.demo;

import com.inspur.ribbon.config.ConsumerRibbonClientConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration;
import org.springframework.cloud.netflix.ribbon.RibbonClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 *    
 * 入口
 *
 * @desc:
 * @author: li.peng02
 * @date: 2019/3/13
 * @version: v1.0 
 */
@SpringBootApplication
@EnableEurekaClient
//@RibbonClient(name = "spring-cloud-producer", configuration = ConsumerRibbonClientConfig.class)
@RibbonClients(defaultConfiguration = RibbonClientConfiguration.class, value = {
        @RibbonClient(name = "spring-cloud-producer", configuration = ConsumerRibbonClientConfig.class)
})
public class CustomerRibbonConfigApplication {

    /**
     * 带有负载均衡的RestTemplate
     *
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate balanceRestTemplate() {
        return new RestTemplateBuilder().build();
    }

    public static void main(String[] args) {
        SpringApplication.run(CustomerRibbonConfigApplication.class, args);
    }
}
